<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .shangpin {
        position: relative;
        width: 300px;
        height: 300px;
    }

    #yuantu {
        position: absolute;
        display: block;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
    }

    .fangdajing {
        display: none;
        position: absolute;
        width: 100px;
        height: 100px;
        opacity: 0.7;
        background-color: blanchedalmond;
    }

    .big {
        display: none;
        position: relative;
        top: -300px;
        left: 300px;
        width: 500px;
        height: 500px;
        overflow: hidden;
    }

    #bigtu {
        position: absolute;
        display: block;
        left: 36.666px;
        top: 36.666px;
        width: 1280px;
        height: 1280px;
    }
</style>

<body>
    <div class="shangpin">
        <img src="D:\Program Files(x86)\steamapps\workshop\content\431960\2871049687\preview.gif" id="yuantu">
        <div class="fangdajing"></div>
    </div>
    <div class="big">
        <img src="D:\Program Files(x86)\steamapps\workshop\content\431960\2871049687\preview.gif" id="bigtu">
    </div>
    <script>
        var shangpin = document.querySelector('.shangpin');
        var yuantu = document.querySelector('#yuantu');
        var fangdajing = document.querySelector('.fangdajing');
        var big = document.querySelector('.big');
        var bigtu = document.querySelector('#bigtu');
        shangpin.addEventListener('mouseover', function () {
            fangdajing.style.display = 'block';
            big.style.display = 'block';
        })
        shangpin.addEventListener('mouseout', function () {
            fangdajing.style.display = 'none';
            big.style.display = 'none';
        })
        shangpin.addEventListener('mousemove', function (e) {
            var x = e.pageX - shangpin.offsetLeft;
            var y = e.pageY - shangpin.offsetTop;
            var X = x - fangdajing.offsetWidth / 2;
            var Y = y - fangdajing.offsetHeight / 2;
            if (X <= 0) {
                X = 0;
            } else if (X >= shangpin.offsetWidth - fangdajing.offsetWidth) {
                X = shangpin.offsetWidth - fangdajing.offsetWidth;
            }
            if (Y <= 0) {
                Y = 0;
            } else if (Y >= shangpin.offsetWidth - fangdajing.offsetWidth) {
                Y = shangpin.offsetWidth - fangdajing.offsetWidth;
            }
            fangdajing.style.left = X + 'px';
            fangdajing.style.top = Y + 'px';
            bigtu.style.left = -5.12 * (X - shangpin.offsetLeft) + 'px';
            bigtu.style.top = -5.12 * (Y - shangpin.offsetTop) + 'px';
        })
    </script>
</body>

</html>